<%include file="header.mako" />
<%namespace name="app" file="tuttfuncs.mako"/>
    <script>
    $(function() { 
      % if user:
      $('#completed_on_date').datepicker();
      $('#start_date').datepicker();
      $('#estimate_finished_date').datepicker();
      $('#add-depend-dlg').dialog({ autoOpen: false,
                                  height: 250,
                                  title: 'Add Dependency',
                                  width: 575 });

      % endif
      });
    </script>
</head>
<body class="container_16">
<div class="grid_16">
<h2 class="cc">Colorado College - Tutt Library Systems</h2>
<h1>Task: ${task.description}</h1>
</div>
<div class="clear"></div>
<div class="grid_10">
<input type="hidden" id="entity-key" value="${task.key()}" />
<input type="hidden" id="entity-type" value="task" />
<table id="tasks-table">
<tr>
  <th>Field</th>
  <th>Value</th>
% if user:
  <th>Actions</th>
% endif  
 </tr>
 <tr>
   <th class="fld">Created on:</th>
   <td>${task.created_on}</td>
% if user:
   <td>READ-ONLY</td>
% endif
 </tr>
 <tr class="alt">
   <th class="fld">Created By:</th>
   <td>${task.created_by}</td>
% if user:
   <td>READ-ONLY</td>
% endif
 </tr>
 <tr>
  <th class="fld">External Milestone?</th>
  <td>
% if user:
  <select id="is_milestone">
% if task.is_milestone:
  <option value="True" selected="selected">Yes</option>
  <option value="False">No</option>
% else:
  <option value="True">Yes</option>
  <option value="False" selected="selected">No</option> 
% endif
  </select>
% else:
% if task.is_milestone:
  Yes
% else:
  No
% endif
% endif
% if user:
 <td>
  <button onclick="Update('is_milestone')">Update</button>
 </td>
% endif
 </tr>
 <tr>
<%
  if task.completed_on_date:
      completed_on_date = task.completed_on_date.strftime('%m/%d/%Y')
  else:
      completed_on_date = 'Not set'  
%>
  <th class="fld">Completed on:</th>
  <td>
    % if user:
    <input type="text" id="completed_on_date" value="${completed_on_date}" />
    % else:
    ${completed_on_date}
    % endif

  </td>
% if user:
   <td><button onclick="Update('completed_on_date')">Update</button></td>
% endif  
 </tr>
 <tr class="alt">
   <th class="fld">Description</th>
   <td>
% if user:
   <textarea name="description" id="description" rows="4" cols="40">${task.description}</textarea>
% else:
   ${task.description}
% endif
   </td>
% if user:
   <td valign="top"><button onclick="Update('description')">Update</button></td>
% endif
 </tr>
<%
  if task.start_date:
    start_date = task.start_date.strftime('%m/%d/%Y')
  else:
    start_date = 'Not set'
%>
 <tr>
   <th class="fld">Start date</th>
   <td>
% if user:
   <input type="text" id="start_date" value="${start_date}" />
% else:
  ${start_date}
% endif
  </td>
% if user:
   <td><button onclick="Update('start_date')">Update</button></td>
% endif
 </tr>
<% 
 if task.estimate_finished_date:
   finish_date = task.estimate_finished_date.strftime('%m/%d/%Y')
 else:
   finish_date = 'Not set'
%>
 <tr class="alt">
   <th class="fld">Estimated Finished Date:</th>
   <td>
% if user:
   <input type="text" id="estimate_finished_date" value="${finish_date}" />
% else:
   ${finish_date}
% endif
  </td>
% if user:
   <td><button onclick="Update('estimate_finished_date')">Update</button></td>
% endif
 </tr>
 <tr>
   <th class="fld">Assigned To:</th>   
   <td>
    <ol>
    % for row in task.get_assignees():
     <li>${row.given}
	 % if user:
	   ${row.family} 
	   <button onclick="RemoveAssignee('${row.key()}')">Remove</button>
	 % endif
	 </li>
    % endfor
   </td>
% if user:
   <td><button onclick="AddAssignee()">Add Assignee</button></td>
% endif   
 </tr>
 <tr class="alt">
  <th class="fld">Tags:</th>
  <td>
  % for tag in task.tags:
  <p>${tag}
   % if user:
   <button onclick="RemoveTag('${tag}')">Remove </button>
   % endif   
  </p>
  % endfor
  </td>
% if user:
   <td><button onclick="AddTag()">Add Tag</button></td>
% endif   
 </tr>
 <tr>
  <th class="fld">History:</th>
  <td>
   % for row in task.get_logs():
   <p><b>Start:</b> ${row.days[0].strftime('%m-%d-%Y')} ${row.description}
      <br/><b>End:</b> ${row.days[-1].strftime('%m-%d-%Y')}
    % if user:
     <button onclick="RemoveDay('row')">Remove</button>
    % endif
   </p>
   % endfor
  </td>
% if user:
   <td><button onclick="AddDay()">Add</button></td>
% endif   
</table>
</div>
<div class="clear"></div>
<%include file="footer.mako" />
